package com.itheima.travel.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.travel.dao.RouteDao;
import com.itheima.travel.domain.Route;
import com.itheima.travel.service.RouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RouteServiceImpl implements RouteService {
    @Autowired
    private RouteDao routeDao;
    @Override
    public PageInfo<Route> findByPageByCid(int cid, int pageNum,String rname) {
        PageHelper.startPage(pageNum,3);
        List<Route> routeList = routeDao.findRouteByCid(cid,rname);
        PageInfo<Route> pageInfo = new PageInfo<>(routeList);

        return pageInfo;
    }

    @Override
    public Route findRoute(int rid) {
        Route route = routeDao.findRoute(rid);

        return route;
    }

    @Override
    public Route findRouteByRid(int rid) {
        return     routeDao.findRouteByRid(rid);
    }
}
